﻿// -----------------------------------------------------------------------
// <copyright file="SearchMask.cs" company="Abyssalsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Gui.Player.Playlist
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Metal.Player.Playlist;

    /// <summary>
    /// Search mask
    /// </summary>
    public partial class SearchMask : Gui.BaseMask.BaseMask, ISearchView
    {
        #region Members

        /// <summary> Represents the controller for this mask </summary>
        private SearchController controller;

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the SearchMask class.
        /// </summary>
        public SearchMask()
        {
            try
            {
                this.InitializeComponent();

                this.controller = new SearchController(this);

                this.ApplyTheme();

                GetControl("SearchTextBox").Select();
            }
            catch (Exception ex)
            {
                Metal.User.UserMessage.ShowError(ex);
            }
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the list data set
        /// </summary>
        public DataSet ListDataSet
        {
            get
            {
                return (GetControl("List") as Gui.Controls.MetalList).ListDataSet;
            }

            set
            {
                (GetControl("List") as Gui.Controls.MetalList).ListDataSet = value;

                if (GetControl("SearchTextBox") != null)
                {
                    GetControl("SearchTextBox").Select();
                }
            }
        }

        /// <summary>
        /// Gets the selected item
        /// </summary>
        public DataGridViewRow ListSelectedRow
        {
            get
            {
                if ((GetControl("List") as Gui.Controls.MetalList).SelectedRows.Count > 0)
                {
                    return (GetControl("List") as Gui.Controls.MetalList).SelectedRows[0];
                }
                else
                {
                    return null;
                }
            }
        }

        #endregion
    }
}
